package com.prs.crm.domain;

import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.prs.crm.domain.sys.Code;

@MappedSuperclass
public class FlowCodeEntity extends FlowEntity{

	private static final long serialVersionUID = 1L;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@Cascade({org.hibernate.annotations.CascadeType.ALL,org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
	@NotFound(action = NotFoundAction.IGNORE)
	private Code code;

	public void setCode(Code code) {
		this.code = code;
		this.code.setEntityName(this.getClass().getName());
	}

	public Code getCode() {
		return code;
	}
}
